package com.mediacloud.app.newsmodule.view

import android.view.View
import android.widget.ImageView
import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.mediacloud.app.model.news.ProgramListItem
import com.mediacloud.app.newsmodule.R

/**
Date:2021/7/21
Author:Wy
 */
class RightAdapter(layoutResId: Int) : BaseQuickAdapter<ProgramListItem, BaseViewHolder>(layoutResId) {

    var isAudio = false

    override fun convert(helper: BaseViewHolder, item: ProgramListItem?) {
        val text_time = helper.getView<TextView>(R.id.text_time)
        val text_title = helper.getView<TextView>(R.id.text_title)
        val text_huikan = helper.getView<TextView>(R.id.text_huikan)
        val text_playing = helper.getView<TextView>(R.id.text_playing)
        val img_zhibozhong = helper.getView<ImageView>(R.id.img_zhibozhong)

        item?.let {
            text_time.text = it.starttime.substring(11, 16)
            text_title.text = it.name
            text_huikan.text = if (isAudio) "回听" else "回看"
            text_playing.text = if (isAudio) "广播中" else "直播中"
            when (ProgramListItem.getItemState(it)) {
                ProgramListItem.GuideItemState.REPLAY -> {
                    text_huikan.visibility = View.VISIBLE
                    img_zhibozhong.visibility = View.GONE
                }
                ProgramListItem.GuideItemState.LIVE -> {
                    text_huikan.visibility = View.GONE
                    img_zhibozhong.visibility = View.VISIBLE
                }
                ProgramListItem.GuideItemState.COMING_SOON -> {
                    text_huikan.visibility = View.GONE
                    img_zhibozhong.visibility = View.GONE
                }
                ProgramListItem.GuideItemState.NONE -> {
//                    text_huikan.visibility = View.GONE
                }
            }

            if (it.selected) {
                text_huikan.visibility = View.GONE
                text_playing.visibility = View.VISIBLE
            } else {
                text_playing.visibility = View.GONE
            }

        }

    }
}